﻿// -----------------------------------------------------------------------
// <copyright file="VehicleGenerator.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Ex03.GarageLogic
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class VehicleGenerator
    {
        private const int k_NumOfModels = 5;
        private string[] m_Models;

        public string[] ModelsNames
        {
            get
            {
                return m_Models;
            }
        }

        public VehicleGenerator()
        {
            m_Models = new string[k_NumOfModels];
            m_Models[0] = "Electric Car";
            m_Models[1] = "Car";
            m_Models[2] = "Electric Motorcycle";
            m_Models[3] = "Motorcycle";
            m_Models[4] = "Truck";
        }

        public StringBuilder PrintModelNames()
        {
            StringBuilder modelsNamesString = new StringBuilder();
            for (int i = 0; i < m_Models.Length; i++)
            {
                modelsNamesString.Append(i + 1);
                modelsNamesString.Append(") ");
                modelsNamesString.Append(m_Models[i]);
            }

            return modelsNamesString;
        }

        public Vehicle CreateNewVehicle(eVehicleType i_VehicleType)
        {
            Vehicle vehicleToCreate = null;
            switch (i_VehicleType)
            {
                case eVehicleType.ElectricCar: 
                {
                    vehicleToCreate = new Car(EnergySource.eEnergySourceType.Electricity);
                    break;
                }

                case eVehicleType.FueledCar:
                {
                    vehicleToCreate = new Car(EnergySource.eEnergySourceType.Octan98);
                    break;
                }

                case eVehicleType.ElectricMotorcycle:
                {
                    vehicleToCreate = new Motorcycle(EnergySource.eEnergySourceType.Electricity);
                    break;
                }

                case eVehicleType.FueledMotorCycle:
                {
                    vehicleToCreate = new Motorcycle(EnergySource.eEnergySourceType.Octan98);
                    break;
                }

                case eVehicleType.Truck:                    
                {
                    vehicleToCreate = new Truck();
                    break;
                }
            }

            return vehicleToCreate;
        }

         public enum eVehicleType
         {
            ElectricCar = 1,
            FueledCar = 2,
            ElectricMotorcycle = 3,
            FueledMotorCycle = 4,
            Truck = 5
         }
    }
}
